namespace go api

struct BaseReq {
    1: string hello
}

struct BaseResp {
    1: i64 status_code
    2: string status_message
    3: i64 service_time
}

struct User {
    1: string user_id
    2: string username
    3: string avatar
}

struct CreateUserRequest {
    1: string username (api.form="username", api.vd="len($) > 0")
    2: string password (api.form="password", api.vd="len($) > 0")
}

struct CreateUserResponse {
    1: BaseResp base_resp
}

struct CheckUserRequest {
    1: string username (api.form="username", api.vd="len($) > 0")
    2: string password (api.form="password", api.vd="len($) > 0")
}

struct CheckUserResponse {
    1: BaseResp base_resp
}

struct GetVideoInfoRequest {
    1: string video_id (api.path="video_id", api.vd="len($) > 0")
}

struct GetVideoChunkRequest {
    1: string video_id (api.path="video_id", api.vd="len($) > 0")
    2: i32 chunk_id (api.query="chunk_id")
}

struct GetVideoInfoResponse {
    1: BaseResp base_resp
    2: i64 total_bytes
    3: i32 total_chunks
}

struct GetVideoChunkResponse {
    1: BaseResp base_resp
}

service ApiService {
    CreateUserResponse CreateUser(1: CreateUserRequest req) (api.post="/v1/user/register")
    CheckUserResponse CheckUser(1: CheckUserRequest req) (api.post="/v1/user/login")
    BaseResp SayHello(1: BaseReq req) (api.get="/v1/test/sayHello")

    GetVideoInfoResponse GetVideoInfo(1: GetVideoInfoRequest req) (api.get="/v1/video/info/:video_id")
    GetVideoChunkResponse GetVideoChunk(1: GetVideoChunkRequest req) (api.get="/v1/video/chunk/:video_id")
}